package org.oschina.zb.platform.localmsg.mq;

import java.io.IOException;

import org.oschina.zb.platform.localmsg.util.JsonAdapter;
import org.oschina.zb.platform.utils.logger.LoggerUtils;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;

/**
 * 消费者基类.
 * 
 * @author donghu
 *
 */
public abstract class QConsumer {

	private static LoggerUtils logger = LoggerUtils.getLogger(QConsumer.class);

	@RabbitHandler
	public void process(String sMessgae) {

		QMessage qMessage;
		try {
			qMessage = JsonAdapter.json2Object(sMessgae, QMessage.class);
		} catch (IOException e) {
			logger.error("[失败]-[队列消费者]-[json转换失败]", e);
			return;
		}
		doProcess(qMessage);
	}

	public abstract void doProcess(QMessage qMessage);

}